package com.sk.sourcecircle.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sk.sourcecircle.R;
import com.sk.sourcecircle.entity.EventListBean;

import java.util.List;

/**
 * Created by sk on 2017/12/12.
 */

public class EventListAdapter extends BaseQuickAdapter<EventListBean.DataBean, BaseViewHolder> {


    public EventListAdapter(int layoutResId, @Nullable List<EventListBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, EventListBean.DataBean item) {
        helper.setText(R.id.event_name, item.getName())
                .setText(R.id.tv_name, item.getCommunity_name())
                .setText(R.id.tv_location,item.getAddress())
                .setText(R.id.tv_time, item.getStart_name() + " 开始");
        Glide.with(mContext).load(item.getHead_url()).into((ImageView) helper.getView(R.id.item_bg));

        if(Double.parseDouble(item.getMin_price())>0){

            helper.setText(R.id.tv_price,"￥"+item.getMin_price()).setTextColor(R.id.tv_price, Color.parseColor("#ff5050"));

        }else {
            helper.setText(R.id.tv_price,"免费").setTextColor(R.id.tv_price, Color.parseColor("#219021"));

        }

        ImageView imageView = helper.getView(R.id.vip);
        switch (item.getCommunity_type()){
            case 1:
                imageView.setVisibility(View.VISIBLE);
                imageView.setImageResource(R.mipmap.group_vip);
                break;
            case 2:
                imageView.setVisibility(View.VISIBLE);
                imageView.setImageResource(R.mipmap.vip_icon);
                break;
            case 3:
                imageView.setVisibility(View.VISIBLE);
                imageView.setImageResource(R.mipmap.person_vip);
                break;
        }

    }

}
